package com.five.api.controller;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.five.api.dao.ArticleTypeMapper;
import com.five.api.service.ArticleTypeService;
import com.five.controller.BaseController;
import com.five.entity.ArticleType;
import com.five.vo.BaseResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import java.util.List;

/**
 * <p>
 * 文章分类表 前端控制器
 * </p>
 *
 * @author star
 * @since 2021-06-16
 */
@RestController
@CrossOrigin
@RequestMapping("article-type")
@Api(tags = "文章分类业务")
public class ArticleTypeController extends BaseController {

    @Autowired
    private ArticleTypeMapper articleTypeMapper;

    @ResponseBody
    @RequestMapping(value = "type", method = RequestMethod.GET)
    @ApiOperation("文章分类")
    public BaseResultVO articleClassify() {
        List articleType = articleTypeMapper.selectArticleType();
        return successResp(articleType);

    }

    @Autowired
    private ArticleTypeService articleTypeService;

    @ResponseBody
    @RequestMapping(value = "query",method = RequestMethod.POST)
    @ApiOperation("获取文章类型列表")
    public BaseResultVO<ArticleType> query(){
        BaseMapper<ArticleType> baseMapper = articleTypeService.getBaseMapper();
        List<ArticleType> articleTypes = baseMapper.selectList(null);
        return successResp(articleTypes);
    }

    @GetMapping("selectArticleTypes")
    public BaseResultVO selectArticleTypes(){
        List<ArticleType> articleTypes = articleTypeService.selectArticleTypes();
        return successResp(articleTypes);
    }
}
